package com.example.blueconn.conn;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

import androidx.lifecycle.MutableLiveData;

import com.example.blueconn.App;

public class ConnService {
    private static final String TAG = "ConnService";

    public static final MutableLiveData<Boolean> wifiService = new MutableLiveData<>(false);
    public static final MutableLiveData<Boolean> bleService = new MutableLiveData<>(false);
    private static final ConnService connService = new ConnService();

    private ConnService() {
    }

    public static ConnService Instance() {
        return connService;
    }

    public static boolean isWifiConnected() {
        ConnectivityManager connectivityManager = (ConnectivityManager) App.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivityManager != null) {
                NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
                if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
                    return networkInfo.isConnected();
                } else {
                    Log.i(TAG, "isWifiConnected: networkinfo is null");
                }
//            }
        }
        return false;
    }

    public static boolean isBleConnected() {
        return false;
    }
}
